
<html>
<head><title>CS143 Project 1B Demo</title></head>
<body>

<form method="GET">
<textarea name="query" cols="60" rows="8"></textarea>
<input type="submit" value="Submit" />
</form>
<?php
$m_query ="";
         if(isset($_GET["query"]) ? $_GET["query"] : null)
        	$m_query = $_GET["query"];

	 $db_connection = mysql_connect("localhost", "cs143", "");
     mysql_select_db("CS143", $db_connection);
	 $rs = mysql_query($m_query, $db_connection); 
	 $n_row = mysql_num_rows($rs);
     $n_field = mysql_num_fields($rs);
echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";

for($i=0; $i<$n_field; $i++)
{
   // $field = mysql_fetch_field($rm);
   // echo "<td>{$field->name}</td>";
   print "<th>".mysql_field_name($rs, $i)."</th>"; 
}
	 echo "</tr>\n";
	 while($row = mysql_fetch_row($rs))
{
    echo "<tr>";

    foreach($row as $cell)
        echo "<td>$cell</td>";

    echo "</tr>\n";
}
mysql_free_result($rs);


mysql_close($db_connection);

?>

</body>
</html>
